import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
import { NestExpressApplication } from '@nestjs/platform-express';
import { PORT } from './common/constants/env';

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);

  // see: https://docs.nestjs.com/openapi/introduction
  // Swagger 配置
  const config = new DocumentBuilder()
    .setTitle('幸福小家 API 文档')
    .setDescription('接口描述')
    .setVersion('1.0')
    // 启用 Bearer Token 认证（如 JWT）
    .addBearerAuth()
    .build();

  const document = SwaggerModule.createDocument(app, config);
  // 访问路径 http://localhost:6001/api
  SwaggerModule.setup('api', app, document);

  await app.listen(PORT);
  console.log(`Application is running on: ${await app.getUrl()}`);
  console.log(`Api Swagger: http://localhost:6001/api`);
}
bootstrap();
